<!--{include(pe_tpl('header.html'));}-->
<div class="right_page">
	<div class="now">
		<a href="admin.php?mod=user" <!--{if(!$_g_userlevel_id):}-->class="sel"<!--{endif;}-->>会员列表（{$tongji['all']}）<i></i></a>
		<!--{foreach($cache_userlevel as $k=>$v):}-->
		<a href="admin.php?mod=user&userlevel_id={$k}" <!--{if($_g_userlevel_id==$k):}-->class="sel"<!--{endif;}-->>{$v['userlevel_name']}（{$tongji[$k]}）<i></i></a>		
		<!--{endforeach;}-->
		<a href="admin.php?mod=user&act=add" onclick="return pe_dialog(this, '添加会员', 700, 650)" id="fabu">添加会员</a>
		<div class="clear"></div>
	</div>
	<div class="right_main">
		<div class="search">
			<form method="get">
			<input type="hidden" name="mod" value="{$_g_mod}" />
			<input type="hidden" name="userlevel_id" value="{$_g_userlevel_id}" />
			用户帐号：<input type="text" name="name" value="{$_g_name}" class="inputtext input100 mar5"/>
			姓名：<input type="text" name="tname" value="{$_g_tname}" class="inputtext input100 mar5"/>
			手机号码：<input type="text" name="phone" value="{$_g_phone}" class="inputtext input100 mar5" />
			推荐人：<input type="text" name="tguser_name" value="{$_g_tguser_name}" class="inputtext input100" />
			<select name="orderby" class="selectmini">
			<option value="">= 默认排序 =</option>
			<!--{$selnum=1;}-->
			<!--{foreach(array('ltime|desc'=>'最近登录', 'money|desc'=>'最多余额', 'point|desc'=>'最多积分', 'ordernum|desc'=>'最多订单') as $k=>$v):}-->
			<option value="{$k}" <!--{if($_g_orderby==$k):}-->selected="selected"<!--{endif;}-->>{$selnum++}){$v}</option>
			<!--{endforeach;}-->
			</select>
			<input type="submit" value="搜索" class="input_btn" />
			</form>
		</div>
		<form method="post" id="form">
		<table width="100%" border="0" cellspacing="0" cellpadding="0" class="list">
		<tr>
			<th class="bgtt" width="20"><input type="checkbox" name="checkall" onclick="pe_checkall(this, 'user_id')" /></th>
			<th class="bgtt" width="50">ID号</th>
			<th class="bgtt" width="40"></th>
			<th class="bgtt">用户帐号</th>
			<th class="bgtt" width="60">姓名</th>
			<th class="bgtt" width="80">钱包</td>
			<th class="bgtt" width="80">积分</th>
			<th class="bgtt" width="80">手机号码</th>
			<th class="bgtt" width="80">订单数</td>
			<th class="bgtt" width="120">推荐人</th>
			<th class="bgtt" width="60">邀请数</th>
			<th class="bgtt" width="80">账号状态</th>
			<th class="bgtt" width="100">注册日期</th>
			<th class="bgtt" width="150">操作</th>
		</tr>
		<!--{foreach($info_list as $v):}-->
		<tr>
			<td><input type="checkbox" name="user_id[]" value="{$v['user_id']}"></td>
			<td>{$v['user_id']}</td>
			<td><img src="{pe_thumb($v['user_logo'], 100, 100, 'avatar')}" width="40" height="40" style="border-radius:50%" /></td>
			<td class="left">
				<span class="">{$v['user_name']}</span>
				<div class="mat5"><span class="tag_blue">{$cache_userlevel[$v['userlevel_id']]['userlevel_name']}</span></div>
			</td>
			<td>{$v['user_tname']?$v['user_tname']:'-'}</td>
			<td><span class="corg">{$v['user_money']}</span></td>
			<td>{$v['user_point']}</td>
			<td>{$v['user_phone']}</td>
			<td><a href="admin.php?mod=order&user_id={$v['user_id']}" class="cblue" target="_blank">{$v['user_ordernum']}</a></td>
			<td>{$v['tguser_id']?$v['tguser_name']:'-'}</td>
			<td><!--{if($v['user_tgnum']):}--><a href="admin.php?mod=user&act=tglist&id={$v['user_id']}" onclick="return pe_dialog(this, '已邀请用户关系图', 500, 600)" style="background:#ccc;border-radius:50%;width:22px;;height:22px; line-height:22px; display:inline-block;color:#fff">{$v['user_tgnum']}</a><!--{else:}-->-<!--{endif;}--></td>
			<td class="layui-form">
				<input type="checkbox" <!--{if($v['user_state']==1):}-->checked<!--{endif;}--> lay-skin="switch" lay-text="正常|冻结" url="admin.php?mod=user&act=state&id={$v['user_id']}&token={$pe_token}" />
			</td>
			<td>{pe_date_color(pe_date($v['user_atime'], 'm-d H:i'))}</span></td>
			<td>
				<a href="admin.php?mod=user&act=edit&id={$v['user_id']}&{pe_jump()}" class="admin_edit mar3">修改</a>
				<a href="javascript:pe_confirm('删除', 'admin.php?mod=user&act=del&id={$v['user_id']}&token={$pe_token}')" class="admin_del mar3">删除</a>
				<a href="user.php" target="_blank" onclick="return login_btn('admin.php?mod=user&act=login&id={$v['user_id']}&token={$pe_token}')" class="admin_btn">登录</a>
			</td>
		</tr>
		<!--{endforeach;}-->
		</table>
		</form>
	</div>
	<div class="right_bottom">
		<span class="fl">
			<input type="checkbox" name="checkall" onclick="pe_checkall(this, 'user_id')" />
			<input type="button" onclick="pe_checksel('user_id') && pe_confirm('批量删除', 'admin.php?mod=user&act=del&token={$pe_token}', 'user_id')" value="批量删除" />
			<!--<input type="button" value="批量发送邮件" id="sendemail" />
			<input type="button" value="批量发送短信" onclick="send_sms();" />-->
		</span>
		<span class="fr fenye">{$db->page->html}</span>
		<div class="clear"></div>
	</div>
</div>
<link rel="stylesheet" href="{$pe['host']}include/plugin/layui/css/layui.css">
<script src="{$pe['host']}include/plugin/layui/layui.js"></script>
<script type="text/javascript">
$(function(){
	/*var ips = new Array();
	$(".ipname").each(function(){
		ips.push($(this).attr("ip"));
	})
	$.getJSON("http://www.phpshe.com/index.php?mod=api&act=ipname&ips="+ips.join(",")+"&callback=?", function(json){
		$(".ipname").each(function(index){
			$(this).find("a").html(json.ipname[index]);
		})
	})*/
	$("#sendemail").click(function(){
		if ($("input[name='user_id[]']:checked").length == 0) {
			alert('请勾选需要发送的用户!');
			return false;
		}
		var user_id = new Array();
		$("input[name='user_id[]']:checked").each(function(){
			user_id.push($(this).val());
		})
		url = 'admin.php?mod=user&act=email&id='+user_id.join(",");
		art.dialog.open(url, {title:'发送邮件', width: 730, height: 470, id: 'sendemail'});
	})
})
layui.use(['form'], function(){
	form = layui.form;
	form.on('switch', function(data){
		var url = $(this).attr("url") + "&value=" + (this.checked ? 1 : 0)
		pe_get(url);
	});
});
//会员登录
function login_btn(url) {
	var result = false;
	$.ajaxSettings.async = false;
	pe_get(url, function(json){
		if (json.code == 1) result = true;
	})
	return result;
}
//批量发送短信
function send_sms() {
	pe_dialog('admin.php?mod=user&act=send_sms', '批量发送短信', 730, 480, 'send_sms');
}
//选择用户
function select_user_open() {
	pe_dialog('admin.php?mod=user&act=select', '选择用户', 730, 600);
}
</script>
<!--{include(pe_tpl('footer.html'));}-->